package com.hh.servlet.subject;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hh.dao.SubjectDAO;

/**
 * Servlet implementation class SubjectList
 */
@WebServlet("/SubjectList")
public class SubjectList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SubjectList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setHeader("content-type", "text/html;charset=UTF-8");
		String zyhm = request.getParameter("zyhm");
		String ygdm = request.getParameter("ygdm");
		if(zyhm==null||ygdm==null){
			response.getWriter().print("请传入住院号码和员工代码");
		}else{
			request.getSession().setAttribute("ygdm", ygdm);
			request.getSession().setAttribute("zyhm", zyhm);
			SubjectDAO dao = new SubjectDAO();
			JSONArray array = dao.getAssessesByZyhm(zyhm);
			JSONObject user = dao.getUser(zyhm);
			JSONArray assesslist = dao.getAssesses();
			request.setAttribute("list", array);
			request.setAttribute("assesslist", assesslist);
			request.setAttribute("user", user);
			request.getRequestDispatcher("subjectlist.jsp").forward(request,response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
